﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Gui
{
    class RP360Pedal
    {
        List<OldRPParam> parameters;
        Dictionary<string, string> newParams;
        //public string name;
        //public 
        PedalType type;
        //public OldRPFxType fxType;
        //public bool Enable = false;
        public delegate void Error(OldRPParamID id, string message);
        public event Error ParseError;

        public RP360Pedal()
        {
            parameters = new List<OldRPParam>();
            newParams = new Dictionary<string, string>();
        }

        public void AddParam(OldRPParam param)
        {
            parameters.Add(param);

        }

        override public string ToString()
        {
            return "";
        }

        internal void Build(RPPedal pedals)
        {
            // find type
            foreach (OldRPParam p in parameters)
            {
                OldRPParamID id = (OldRPParamID)ulong.Parse(p.ID);

                if ((id >= OldRPParamID.AmpChannel_AB) && (id <= OldRPParamID.BChanEqTrebleLevel_n12_12))
                {
                    if (null != ParseError)
                        ParseError.Invoke(id, "RP360 does not support 2 channels on amplifier.");

                    return;
                }

                CommonPedal pedal;
                Param param = pedals.FindById(id, @pedal);
                if (null == param)
                {
                    if (null != ParseError)
                        ParseError.Invoke(id, "Parameter not found.");
                }
                else
                {
                    newParams.Add(BuildName(param, GetPedalType(pedal)), param.value.ToString());
                }
            }
        }

        private PedalType GetPedalType(CommonPedal pedal)
        {
            throw new NotImplementedException();
        }

        private string BuildName(Param param, PedalType type)
        {
            throw new NotImplementedException();
        }
    }
}
